/**
 * Created by hang on 14-5-11.
 */
var host = "";
$(document).ready(function(){
	host = "http://114.215.121.115/xipujewelWeb";

    setShopCartCount();
});

function setShopCartCount(){
    $.post(host + "/ShopCart/getShopCartCount",function (data) {
        if (data != null) {
            $("#shopCartCount").text(data);
            $("#shopCartCount2").text(data);
        }
    });
}

function updatePassword() {
    var oldPassword = $("#odlPassword").val();
    var newPassword = $("#newPassword").val();
    var newPassword2 = $("#newPassword2").val();
    if (newPassword != newPassword2) {
        alert("确认密码与新密码不相同");
    } else {
        $.post(host+"/account/user/updatePassword", {oldPassword: oldPassword, newPassword: newPassword},
            function (data) {
                if (data != null) {
                    alert(data);
                }
            });
    }
}

function saveAddress() {
    var name = $("#shopAddress_name").val();
    var cell = $("#shopAddress_cell").val();
    var cellphone = $("#shopAddress_cellphone").val();
    var address = $("#shopAddress_address").val();
    var remark = $("#shopAddress_remark").val();
    var email = $("#shopAddress_email").val();
    var fax = $("#shopAddress_fax").val();
    $.post(host+"/address/save", {filter_name: name, filter_cell: cell,
            filter_cellphone: cellphone, filter_address: address, filter_remark: remark, filter_email: email, filter_fax: fax},
        function (data) {
            alert(data);
//                        location.reload();
        });
}

function searchOrder() {
    var orderNum = $("#orderNum");
    var orderStatus = $("#orderStatus");
    $.post(host+"/account/user/searchOrder", {filter_EQ_status: orderStatus.val(),
            filter_EQ_orderNum: orderNum.val()},
        function (data) {
            $(data).replaceAll($("#orderTable"));
        });
}

function deleteOrder(id) {
    if (confirm("确认要取消订单？")) {
        $.post(host+"/order/deleteOrder/", {id: id},
            function (data) {
                alert(data);
                location.reload();
                $("passwordDiv").removeClass(".cur");
                $("orderDiv").addClass(".cur");
            });
    }
}
